export enum ActionTypes {
	CHANGE_LANGUAGE,
	ADD_LANGUAGE,
}

interface ChangeLanguageAction {
	type: typeof ActionTypes.CHANGE_LANGUAGE
	payload: "zh" | "en"
}

interface AddLanguageAction {
	type: typeof ActionTypes.ADD_LANGUAGE
	payload: { name: string; code: string }
}

export type LanguageActionTypes = ChangeLanguageAction | AddLanguageAction

export const changeLanguageActionCreator = (languageCode: "zh" | "en"): ChangeLanguageAction => {
	return {
		type: ActionTypes.CHANGE_LANGUAGE,
		payload: languageCode,
	}
}

export const addLanguageActionCreator = (name: string, code: string): AddLanguageAction => {
	return {
		type: ActionTypes.ADD_LANGUAGE,
		payload: { name, code },
	}
}
